#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <message/UMessage>
#include "widgets/umainwindow.h"

#include <QMap>
#include <QPropertyAnimation>

class UToast;
class QStackedWidget;
class UListView;
class TitlesWidget;
class UPushButton;
class QStandardItemModel;
class LoadingDialog;
class ULineEdit;
class UCommonButton;
class UEdgeButton;
class QMouseEvent;
class MainWindow : public UMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget* parent = nullptr);
    ~MainWindow() Q_DECL_OVERRIDE;

    void initUI();

    void initMenu();

    void initTest();

    void showFloatMessage(bool isOK, const QString &message);

    void initListView();

    void initContent();

    void initConnection();

    std::shared_ptr<UMessageResult> test(std::shared_ptr<UMessage> msg);

    void showLoadingDialog(bool isVisible, const QString &text);

protected:
    void changeEvent(QEvent* event) override;

private:
    void initAnimation();

    void handleAnimation(qreal startValue, qreal endValue);

public slots:
    void handleAbout();
    void handleQuit();
    void onChangeWidget(const QModelIndex &index);
    void onChangeCenterWidget(const QModelIndex &index);
    void onGlobalMouseEvent(QMouseEvent* event);

private:
    UToast* toolTip = Q_NULLPTR;
    QMap<int, QWidget*> m_listWidget;
    QWidget *m_leftWidget = Q_NULLPTR;
    UListView* m_listview = Q_NULLPTR;
    QStackedWidget* m_mainWidget = Q_NULLPTR;
    QStackedWidget* m_stackedWidget = Q_NULLPTR;
    TitlesWidget* m_titlesWidget = Q_NULLPTR;
    UCommonButton* m_homeBtn = Q_NULLPTR;
    QList<QAction*> m_actionList;
    QStandardItemModel* m_model = Q_NULLPTR;
    LoadingDialog* m_loadingDialog = Q_NULLPTR;
    ULineEdit* m_seachEdit = Q_NULLPTR;
    UEdgeButton *m_edgeButton = Q_NULLPTR;
    QPropertyAnimation m_propertyAnimation;
};

#endif // MAINWINDOW_H
